rm(list = ls())

impcnt <- 'USA'
EPUtype <- 'eco'
impvar <- 'unctn'
indus <- ''
responseCnt <- 'CHN'
resvar <- 'TFP'
p <- 2

load(paste('./data-raw/',impcnt,'_',EPUtype,impvar,'2',responseCnt,'_',indus,
           resvar,'_p',as.character(p),'.rdata',sep = ''))

xlsx::write.xlsx(Hansen99(countryrlt)$ThrTest,'E:/17_HuaDong/reserch/GVAR/RltPaper/ThresholdTest.xlsx',
                   'Sheet3',append = T,row.names = FALSE)

ADFtest <- Hansen99(countryrlt)$ADFtest
ADFtest$var <- str_replace_all(ADFtest$var,'[A-Z]{3}cpi_FL0','cpi\\*') %>%
  str_replace_all('[A-Z]{3}gdp_FL0','gdp\\*') %>%
  str_replace_all('[A-Z]{3}TFP_FL0','TFP\\*')

dcast(ADFtest, cnt ~ var, value.var = 'pvalue') %>%
  .[,c('cnt','cpi','gdp','TFP','cpi*','gdp*','TFP*')] %>%
  xlsx::write.xlsx('E:/17_HuaDong/reserch/GVAR/RltPaper/ADFTest.xlsx','Sheet3',append = T, row.names = FALSE)

